package site;

import java.io.IOException;
import javax.ejb.EJB;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * Servlet implementation class ArticleServlet
 */
public class ArticleServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;
	
	@EJB
	ArticleManager am ;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public ArticleServlet() {
        super();
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
			String titre = request.getParameter("Titre");
			int jj = Integer.parseInt(request.getParameter("jour"));
			int mm =Integer.parseInt(request.getParameter("mois"));
			int aaaa = Integer.parseInt(request.getParameter("an"));
			String contenu = request.getParameter("contenu");
			am.ajouterArticle (titre,jj,mm,aaaa,contenu);
			request.getRequestDispatcher("Article2.html").forward(request, response);
			
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		doGet(request,response);
	}

}
